package com.chen;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by tfhnia on 2017/8/24.
 */
@RestController
public class HelloController {

    @Value("${cupSize}")
    private String cupSize;

    @Value("${content}")
    private String content;


    @Autowired
    private BoyProperties boy;

    @RequestMapping(value = "/say",method = RequestMethod.GET)
    public String say(){
        return "你好！" + boy.getHeight();
    }

    @RequestMapping(value = {"/hello","/hi"},method = RequestMethod.GET)
    public String hello(){
        return "index";
    }

    //    路由参数，接收 /read/3 形式的请求并读取
    @RequestMapping(value = "/read/{id}",method = RequestMethod.GET)
    public String read(@PathVariable("id") Integer id){
        return "read:" + id;
    }

    //    路由参数，接收 /find?id=value 形式的请求并读取
    @RequestMapping(value = "/find",method = RequestMethod.GET)
    public String find(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myid){
        return "find:" + myid;
    }

    @GetMapping(value = "/get")
    public String MapbyGet(){
        return "简化的RequestMapping，还有PostMapping等";
    }

}
